#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from Framework.Initialize import initialize
from Framework.BrowserEngine import browserEngine
from Utils.PropertiesParsor import ParsePageProperty
from PageObjects.WebQQ.QQHomePage import QQHomePage
from PageObjects.WebWeiXin.WXHomePage import WXHomePage
from PageObjects.ACToys.TransformerTradePage import TransformerTradePage
from Utils.Logger import Logger
from Framework.TestSet import TestSet
from Utils.Report import run_with_text_runner

logger = Logger().get_logger()
parser = ParsePageProperty()
initialize()
driver = browserEngine.launch_local_browser()
webqq = QQHomePage(driver)
webwx = WXHomePage(driver)
actoys = TransformerTradePage(driver)
try:
    if webwx.go():
        if webwx.go_():
            if webqq.go():
                if webqq.go_():
                    if actoys.go():
                        if actoys.go_():
                            suite = TestSet().all_cases()
                            run_with_text_runner(suite)
except Exception as e:
    print(e)
finally:
    webwx.send_messages(2, "喝吊扯", "@王琪瑞 搜索发生异常，程序自动退出，请检查日志并重新启动")
    webqq.send_messages(3, "喝吊扯", "@王琪瑞 搜索发生异常，程序自动退出，请检查日志并重新启动")
    browserEngine.quit_browser()

# for i in range(3):
# suite = TestSet().all_cases()
# run_with_text_runner(suite)
